package org.raymond.iworks.study.basic.feature;

import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class JDK11Test {
    public static void main(String[] args) {
        var jdk11Test = new JDK11Test();
        jdk11Test.notPredicateTest();
        jdk11Test.stringApiTest();
    }

    public void stringApiTest(){
        String s1 = "hello world!";
        System.out.printf("%s, %s, %s, %s\n", s1!=null && s1.isEmpty(), s1.isBlank(), s1.strip(), s1.trim());
    }

    public void notPredicateTest(){
        List<String> sampleList = List.of("张三", "java 11","jack");
        List<String> result = sampleList.stream()
                // 过滤以j开头的字符串, 推断类型var，可用于lamada
                .filter((var s) -> s.startsWith("j"))
                // 同时不包含11的字符串
                .filter(Predicate.not(s -> s.contains("11")))
                .collect(Collectors.toList());
        System.out.printf("%s", result);
    }
}
